package com.vesystem.vegua.modules.common.controller;

import cn.hutool.core.lang.UUID;
import com.vesystem.vegua.modules.common.service.impl.RemoteAppServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @auther hcy
 * @create 2020-12-16 18:52
 * @Description
 */
@Controller
@RequestMapping("extend")
public class PageController {

    @Autowired
    private RemoteAppServiceImpl remoteAppService;

    @GetMapping("uamGetRemotePage")
    public void uamGetRemotePage(HttpServletRequest request, HttpServletResponse response,String authorization, String option) throws IOException {
        if ( remoteAppService.checkUamToken( authorization ) ){
            // 因为uam没有返回登录名，使用uuid替代，对接的时候再去沟通返回登录名的问题
            response.sendRedirect("/static/remote/index.html?sourceType=2&connectionParam="+option+"&loginname="+ UUID.randomUUID().toString());
        }else {
            response.sendRedirect("error");
        }
    }



}
